<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <title>DashSaver</title>
    <style>
        .loader-indicator {
            position: fixed;
            top: 0;
            left: 0;
            right: 0;
            background: #f8f9fa;
            padding: 12px;
            text-align: center;
            font-family: system-ui, sans-serif;
            z-index: 10000;
            box-shadow: 0 2px 5px rgba(0,0,0,0.1);
        }
    </style>
</head>
<body>
    <div class="loader-indicator">LOADING...</div>
    <iframe id="app-container" 
            style="width:100%; height:100vh; border:none;"
            sandbox="allow-scripts allow-same-origin"></iframe>

    <script>
        const CONFIG = {
            repo: 'fastnow/DashSaver',
            branch: 'main',
            targetFile: 'source/html/index.html'
        };

        function getContentUrl() {
            return `https://raw.githubusercontent.com/${CONFIG.repo}/${CONFIG.branch}/${CONFIG.targetFile}?ts=${Date.now()}`;
        }

        async function loadApp() {
            try {
                const iframe = document.getElementById('app-container');
                
                const response = await fetch(getContentUrl());
                if (!response.ok) throw new Error(`HTTP错误: ${response.status}`);
                const html = await response.text();
                
                iframe.srcdoc = html;
                
                iframe.onload = () => {
                    document.querySelector('.loader-indicator').style.display = 'none';
                };
                
            } catch (error) {
                console.error('错误:', error);
                document.querySelector('.loader-indicator').innerHTML = `
                    <div style="color:red; padding:1rem;">
                        <h3>错误</h3>
                        <p>${error.message}</p>
                        <button onclick="window.location.reload()" 
                                style="padding:8px 16px;background:#4285f4;color:white;border:none;border-radius:4px;">
                            重试
                        </button>
                    </div>
                `;
            }
        }

        window.addEventListener('DOMContentLoaded', loadApp);
    </script>
</body>
</html>